﻿Public Class frmTraCuuThoiKhoaBieu

    Private Sub frmTraCuuThoiKhoaBieu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        dgTKB.Rows.Clear()
    End Sub

    Private Sub btTraCuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btTraCuu.Click
        Try
            Dim tkbDTO As New BaoCaoThoiKhoaBieuDTO()
            Dim tkbBUS As New ThoiKhoaBieuBUS()
            Dim kq As Integer = -1

            tkbDTO.TenLop = txtTenLop.Text.Trim()
            If (cbThu.SelectedItem <> Nothing) Then
                tkbDTO.Thu = cbThu.SelectedItem.ToString().Trim()
            End If
            If (cbBuoi.SelectedItem <> Nothing) Then
                tkbDTO.Buoi = cbBuoi.SelectedItem.ToString().Trim()
            End If
            If (cbTiet.SelectedItem <> Nothing) Then
                tkbDTO.Tiet = cbTiet.SelectedItem.ToString().Trim()
            End If
            tkbDTO.TenMonHoc = txtMonHoc.Text.Trim()
            tkbDTO.TenGV = txtGV.Text.Trim()

            Dim ds As New List(Of BaoCaoThoiKhoaBieuDTO)
            Dim i As Integer = 1

            ds = tkbBUS.TraCuuTTTKB(tkbDTO)
            dgTKB.Rows.Clear()

            For Each tkb As BaoCaoThoiKhoaBieuDTO In ds
                dgTKB.Rows.Add(i, tkb.TenLop, tkb.Thu, tkb.Buoi, tkb.Tiet, tkb.TenMonHoc, tkb.TenGV)
                i += 1
            Next

        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub btXoaForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btXoaForm.Click
        txtTenLop.Text = ""
        txtGV.Text = ""
        txtMonHoc.Text = ""
        cbBuoi.SelectedItem = ""
        cbThu.SelectedItem = ""
        cbTiet.SelectedItem = ""
    End Sub

    Private Sub btThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btThoat.Click
        Me.Close()
    End Sub
End Class